﻿using Microsoft.AspNetCore.Mvc.ApplicationModels;
using System;
using System.Collections.Generic;
using System.Text;

namespace JESAI.DynamicWebApi.Configurations
{
    /// <summary>
    /// 动态WebApi程序集设置建造者
    /// </summary>
    public class DynamicWebApiControllerAssemblySettingBuilder: IDynamicWebApiControllerAssemblySettingBuilder
    {
        private readonly DynamicWebApiControllerAssemblySetting _setting;

        public DynamicWebApiControllerAssemblySettingBuilder(DynamicWebApiControllerAssemblySetting setting)
        {
            _setting = setting;
        }

        /// <summary>
        /// 增加Where表达式
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public DynamicWebApiControllerAssemblySettingBuilder Where(Func<Type, bool> predicate)
        {
            _setting.TypePredicate = predicate;
            return this;
        }

        /// <summary>
        /// 配置控制器Model
        /// </summary>
        /// <param name="configurer"></param>
        /// <returns></returns>
        public DynamicWebApiControllerAssemblySettingBuilder ConfigureControllerModel(Action<ControllerModel> configurer)
        {
            _setting.ControllerModelConfigurer = configurer;
            return this;
        }
    }
}
